<?php

namespace App\Admin\Actions\NewsAction;

use App\Models\User;
use Illuminate\Support\Facades\DB;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use OpenAI;

class NewsImageCheck extends RowAction
{
    public $name = '新闻图片展现';
    
    public function handle(Model $model)
    {
	    /**
	     * @var $model User
	     */
    	

	 

		if($model->content_cn){

			$data['content_cn'] = str_replace("_src", "src", $model->content_cn); 
		}

		if($model->content_zn){

			$data['content_zn'] = str_replace("_src", "src", $model->content_zn); 
		}


    	

		 $model->update($data);
	  
    	
    	
	    return $this->response()->success('新闻图片替换完成')->refresh();
    }
	
	public function dialog()
	{
		$this->confirm('确定替换新闻图片吗?');
	}
}
